#include "lolevel.h"
#include "platform.h"
#include "core.h"

static long *nrflag = (long*)0x85C0;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FFD18614_my(){ 
 asm volatile(
                 "STMFD   SP!, {R0-R10,LR}\n"
                 "MOV     R6, #0\n"
                 "MOV     R4, R0\n"
                 "BL      sub_FFD19114\n"
                 "MVN     R1, #0\n"
                 "BL      sub_FFC178B8\n"
                 "MOV     R2, #4\n"
                 "ADD     R1, SP, #8\n"
                 "MOV     R0, #0x8A\n"
                 "BL      sub_FFC5DAB4\n"
                 "TST     R0, #1\n"
                 "LDRNE   R1, =0x218\n"
                 "LDRNE   R0, =0xFFD18828\n"
                 "BLNE    sub_FFC0BDB8\n"
                 "LDR     R8, =0x18980\n"
                 "LDR     R5, =0x188d4\n"
                 "LDRSH   R1, [R8,#0xE]\n"
                 "LDR     R0, [R5,#0x74]\n"
                 "BL      sub_FFCD399C\n"
                 "BL      sub_FFC37744\n"
                 "LDR     R2, =0x85C4\n" 	
                 "ADD     R3, R4, #0x8C\n"
                 "STRH    R0, [R4,#0x88]\n"
                 "STR     R2, [SP]\n"
                 "STR     R3, [SP,#4]\n"
                 "MOV     R1, R0\n"
                 "LDRH    R0, [R5,#0x4C]\n"
                 "LDRSH   R2, [R8,#0xC]\n"
                 "LDR     R3, =0x85C0\n"
				 "BL      sub_FFD19600\n"
                 //"BL      wait_until_remote_button_is_released\n"
                 "BL      capt_seq_hook_set_nr\n"
                 "B       sub_FFD18688\n"
 );
}
void __attribute__((naked,noinline)) task_CaptSeqTask_my() //#fs
{

	asm volatile (
"       STMFD	SP!, {R3-R7,LR}\n"
"		LDR	R6, =0x54C0\n"
"loc_FFC4F100:\n"
		
"		LDR	R0, [R6,#8]\n"
"		MOV	R2, #0\n"
"		MOV	R1, SP\n"
//<========qui
"		BL	sub_FFC17B08\n"
"		TST	R0, #1\n"
"		BEQ	loc_FFC4F12C\n"
"		LDR	R1, =0x48E\n"
"		LDR	R0, =0xFFC4EDF8\n" 
"		BL	sub_FFC0BDB8\n" //debug assert
"		BL	sub_FFC0BB70\n" //exit task
"		LDMFD	SP!, {R3-R7,PC}\n"
"loc_FFC4F12C:\n"	
//"		LDR	R0, [SP,#0x18+var_18]"    <=== qui, ho aggiunto la riga dopo
"       LDR R0, [SP]\n"
"		LDR	R1, [R0]\n"
"		CMP	R1, #0x1A\n"
		"ADDLS	PC, PC,	R1,LSL#2\n"
		"B	loc_FFC4F354\n"
"loc_FFC4F140:\n"				
"		B	loc_FFC4F1AC\n"
"loc_FFC4F144:\n"				
"		B	loc_FFC4F1B4\n"
"loc_FFC4F148:\n"				
"		B	loc_FFC4F23C\n"
"loc_FFC4F14C:\n"				
"		B	loc_FFC4F250\n"
"loc_FFC4F150:\n"				
"		B	loc_FFC4F248\n"
"loc_FFC4F154:\n"				
"		B	loc_FFC4F258\n"
"loc_FFC4F158:\n"				
"		B	loc_FFC4F260\n"
"loc_FFC4F15C:\n"				
		"B	loc_FFC4F26C\n"
"loc_FFC4F160:\n"				
"		B	loc_FFC4F2C4\n"
"loc_FFC4F164:\n"				
		"B	loc_FFC4F250\n"
"loc_FFC4F168:\n"				
		"B	loc_FFC4F2CC\n"
"loc_FFC4F16C:\n"				
		"B	loc_FFC4F2D4\n"
"loc_FFC4F170:\n"				
		"B	loc_FFC4F2DC\n"
"loc_FFC4F174:\n"				
		"B	loc_FFC4F2E4\n"
"loc_FFC4F178:\n"				
"		B	loc_FFC4F2EC\n"
"loc_FFC4F17C:\n"				
"		B	loc_FFC4F2F4\n"
"loc_FFC4F180:\n"				
"		B	loc_FFC4F2FC\n"
"loc_FFC4F184:\n"				
		"B	loc_FFC4F304\n"
"loc_FFC4F188:\n"				
		"B	loc_FFC4F30C\n"
"loc_FFC4F18C:\n"				
		"B	loc_FFC4F318\n"
"loc_FFC4F190:\n"				
		"B	loc_FFC4F324\n"
"loc_FFC4F194:\n"				
		"B	loc_FFC4F32C\n"
"loc_FFC4F198:\n"				
		"B	loc_FFC4F334\n"
"loc_FFC4F19C:\n"				
		"B	loc_FFC4F33C\n"
"loc_FFC4F1A0:\n"				
		"B	loc_FFC4F344\n"
"loc_FFC4F1A4:\n"				
		"B	loc_FFC4F34C\n"
"loc_FFC4F1A8:\n"				
		"B	loc_FFC4F360\n"
"loc_FFC4F1AC:\n"			//jumptable entry 0
		"BL	sub_FFD1717C\n"
		"BL shooting_expo_param_override\n"
		"B	loc_FFC4F264\n"
"loc_FFC4F1B4:\n"			//jumptable entry 1
"		LDR	R4, [R0,#0xC]\n"
"		LDR	R0, [R4,#8]\n"
"		ORR	R0, R0,	#1\n"
"		STR	R0, [R4,#8]\n"
"		MOV	R0, #2\n"
"		BL	sub_FFC4A04C\n"
"		BL	sub_FFD1716C\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD17554\n"
"		TST	R0, #1\n"
"		MOVNE	R2, R4\n"
"		MOVNE	R1, #1\n"
"		BNE	loc_FFC4F2BC\n"
"		BL	sub_FFD35780\n"
"		BL	sub_FFC5DC44\n"
"		STR	R0, [R4,#0x14]\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD1854C\n"
"		BL	sub_FFD18FB0\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD18614_my\n" //sub_ffd0a3cc on a720 get propety
		"BL capt_seq_hook_raw_here\n"
"		MOV	R5, R0\n"
"		BL	sub_FFD19F90\n"
"		BL	sub_FFD19FCC\n"
"		MOV	R2, R4\n"
"		MOV	R1, #1\n"
"		MOV	R0, R5\n"
"		BL	sub_FFC4D860\n"
"		BL	sub_FFD189C4\n"
"		CMP	R0, #0\n"
"		LDRNE	R0, [R4,#8]\n"
"		ORRNE	R0, R0,	#0x2000\n"
"		STRNE	R0, [R4,#8]\n"
"		B	loc_FFC4F360\n"

"loc_FFC4F23C:\n"		//jumptable entry 2		
"		MOV	R0, #1\n"
"		BL	sub_FFD17310\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F248:\n"				
"		BL	sub_FFD16DD0\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F250:\n"				
"		BL	sub_FFD1715C\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F258:\n"
"		BL	sub_FFD17164\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F260:\n"				
"		BL	sub_FFD17230\n"
"loc_FFC4F264:\n"				
"		BL	sub_FFC4D4E0\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F26C:\n"			
"		LDR	R4, [R0,#0xC]\n"
"		BL	sub_FFD1716C\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD178D4\n"
"		TST	R0, #1\n"
"		MOV	R5, R0\n"
"		BNE	loc_FFC4F2AC\n"
"		BL	sub_FFC5DC44\n"
"		STR	R0, [R4,#0x14]\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD1854C\n"
"		MOV	R0, R4\n"
"		BL	sub_FFD18A24\n"
"		MOV	R5, R0\n"
"		LDR	R0, [R4,#0x14]\n"
"		BL	sub_FFC5DE50\n"
"loc_FFC4F2AC:\n"				
"		BL	sub_FFD1715C\n"
"		MOV	R2, R4\n"
"		MOV	R1, #9\n"
"		MOV	R0, R5\n"
"loc_FFC4F2BC:\n"				
"		BL	sub_FFC4D860\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2C4:\n"				
"		BL	sub_FFD17290\n"
"		B	loc_FFC4F264\n"
"loc_FFC4F2CC:\n"				
"		BL	sub_FFD17B50\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2D4:\n"				
"		BL	sub_FFD17D38\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2DC:\n"				
"		BL	sub_FFD17DC8\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2E4:\n"				
"		BL	sub_FFD17E7C\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2EC:\n"				
"		MOV	R0, #0\n"
"		B	loc_FFC4F310\n"
"loc_FFC4F2F4:\n"				
"		BL	sub_FFD18170\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F2FC:\n"				
"		BL	sub_FFD18204\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F304:\n"				
"		BL	sub_FFD182CC\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F30C:\n"				
"		MOV	R0, #1\n"
"loc_FFC4F310:\n"		
"		BL	sub_FFD18020\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F318:\n"
"		BL	sub_FFD1742C\n"
"		BL	sub_FFC14A34\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F324:\n"				
"		BL	sub_FFD17F38\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F32C:\n"				
"		BL	sub_FFD17F7C\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F334:\n"				
"		BL	sub_FFD19F74\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F33C:\n"				
"		BL	sub_FFD19F90\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F344:\n"				
"		BL	sub_FFD19FA0\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F34C:\n"				
		"BL	sub_FFD19FCC\n"
"		B	loc_FFC4F360\n"
"loc_FFC4F354:\n"				
"		LDR	R1, =0x58E\n"
"		LDR	R0, =0xFFC4EDF8\n"		// =aSsshoottask_c
"		BL	sub_FFC0BDB8\n"			//assert
"loc_FFC4F360:\n"
		//"LDR	R0, [SP,#0x18+var_18]\n"
		"LDR     R0, [SP]\n"
"		LDR	R1, [R0,#4]\n"
"		LDR	R0, [R6,#4]\n"
"		BL	sub_FFC17884\n"
		//"LDR	R4, [SP,#0x18+var_18]\n"
		"LDR    R4, [SP]\n"
"		LDR	R0, [R4,#8]\n"
"		CMP	R0, #0\n"
"		LDREQ	R1, =0x10D\n"
"		LDREQ	R0, =0xFFC4EDF8\n"  //"SsShootTask.c"
"		BLEQ	sub_FFC0BDB8\n" //debug assert
"		MOV	R0, #0\n"
"		STR	R0, [R4,#8]\n"
"		B	loc_FFC4F100\n"
);
}
